package hulppakket;

import java.io.Serializable;

public class Point3f extends Tuple3f implements Serializable {

	private static final long serialVersionUID = -7536401677786031430L;

	/**
	 * Constructs and initializes a Point3f to (0,0,0).
	 */
	public Point3f() {
	}

	/**
	 * Constructs and initializes a Point3f from the array of length 3.
	 * 
	 * @param p
	 */
	public Point3f(float p[]) {
		super(p);
	}

	/**
	 * Constructs and initializes a Point3f from the specified xyz coordinates.
	 * 
	 * @param x
	 * @param y
	 * @param z
	 */
	public Point3f(float x, float y, float z) {
		super(x, y, z);
	}

	/**
	 * Constructs and initializes a Point3f from the specified Point3f.
	 * 
	 * @param p
	 */
	public Point3f(Point3f p) {
		super(p);
	}

	/**
	 * Constructs and initializes a Point3f from the specified Tuple3f.
	 * 
	 * @param t
	 */
	public Point3f(Tuple3f t) {
		super(t);
	}

	public float getCoordinate(int axis) throws Exception {
		switch (axis) {
		case 0:
			return this.x;
		case 1:
			return this.y;
		case 2:
			return this.z;
		default:
			throw new Exception("Unknown axis.");
		}
	}
	
	public Point3f add(Vector3f vector){
		return new Point3f(this.x + vector.x, this.y + vector.y, this.z + vector.z);
	}
}
